import socket

sk = socket.socket()#创建socket

#print(sk)

Tp=open('ipinfo.dll','r')
#print(Tp.read())
address = (Tp.read(), 8000)#本机地址
sk.bind(address)#为socket绑定IP和端口号

sk.listen(128)#限制排队的个数
#print('waiting......')
while 1:
    conn, addr = sk.accept()#conn为客户端socket对象
#
# inp = input('>>>')
# conn.send(bytes(inp, 'utf8'))
    data = conn.recv(1048576)#为什么用conn，而不用sk
    #print(str(data, 'utf8'))
    print('saving')
    p=open('painted.txt','w+')
    p.write(str(data,'utf-8'))
    p.close()
    print('saved')

# conn.close()#关具体对象
# sk.close()#全关
